<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>GitCode 代码树查看器</title>
  <style>
    body {
      width: 300px;
      padding: 16px;
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
      font-size: 14px;
      margin: 0;
    }
    .header {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-bottom: 16px;
    }
    .header h1 {
      margin: 0;
      font-size: 18px;
      font-weight: 600;
      color: #24292e;
    }
    .section {
      margin-bottom: 16px;
    }
    .section-title {
      font-weight: 600;
      margin-bottom: 8px;
      color: #586069;
      font-size: 12px;
      text-transform: uppercase;
    }
    .toggle-container {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 8px 0;
    }
    .toggle-label {
      color: #24292e;
    }
    .toggle-switch {
      position: relative;
      width: 44px;
      height: 24px;
      background: #d1d5da;
      border-radius: 12px;
      cursor: pointer;
      transition: background-color 0.2s;
    }
    .toggle-switch.active {
      background: #28a745;
    }
    .toggle-switch::after {
      content: '';
      position: absolute;
      width: 18px;
      height: 18px;
      background: white;
      border-radius: 50%;
      top: 3px;
      left: 3px;
      transition: transform 0.2s;
      box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }
    .toggle-switch.active::after {
      transform: translateX(20px);
    }
    .info {
      padding: 12px;
      background: #f6f8fa;
      border-radius: 6px;
      font-size: 12px;
      color: #586069;
      line-height: 1.5;
    }
    .info strong {
      color: #24292e;
    }
    .shortcut {
      display: inline-block;
      padding: 2px 6px;
      background: #e1e4e8;
      border-radius: 3px;
      font-family: monospace;
      font-size: 11px;
      color: #24292e;
    }
    .token-container {
      display: flex;
      gap: 8px;
      margin-bottom: 8px;
    }
    .token-input {
      flex: 1;
      padding: 8px 12px;
      border: 1px solid #d1d5da;
      border-radius: 6px;
      font-size: 13px;
      font-family: monospace;
    }
    .token-input:focus {
      outline: none;
      border-color: #0366d6;
      box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1);
    }
    .save-button {
      padding: 8px 16px;
      background: #0366d6;
      color: white;
      border: none;
      border-radius: 6px;
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      transition: background-color 0.2s;
    }
    .save-button:hover {
      background: #0256cc;
    }
    .save-button:active {
      background: #0249b8;
    }
  </style>
</head>
<body>
  <div class="header">
    <svg width="24" height="24" viewBox="0 0 16 16" fill="currentColor">
      <path d="M3.75 0a.75.75 0 0 0-.75.75v14.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75V7.5H9.75a.75.75 0 0 1-.75-.75V4.5H3.75a.75.75 0 0 0-.75.75zm5.75.56v2.19h2.19L9.5.56zM2.5 1.5v13h9v-6h-3.5a.75.75 0 0 1-.75-.75v-3.5H2.5z"/>
    </svg>
    <h1>代码树查看器</h1>
  </div>

  <div class="section">
    <div class="toggle-container">
      <span class="toggle-label">启用代码树</span>
      <div class="toggle-switch" id="enableToggle"></div>
    </div>
  </div>

  <div class="section">
    <div class="section-title">API Token</div>
    <div class="token-container">
      <input type="password" id="tokenInput" placeholder="输入GitCode API Token" class="token-input">
      <button id="saveToken" class="save-button">保存</button>
    </div>
    <div class="info" style="margin-top: 8px;">
      <strong>说明：</strong>用于访问GitCode API，获取代码树数据。可在GitCode设置中生成Personal Access Token。
    </div>
  </div>

  <div class="section">
    <div class="section-title">快捷键</div>
    <div class="info">
      按 <span class="shortcut">Alt + T</span> 可以快速显示/隐藏代码树查看器
    </div>
  </div>

  <div class="section">
    <div class="section-title">使用说明</div>
    <div class="info">
      <strong>功能：</strong><br>
      • 在GitCode代码仓库页面右侧显示代码树<br>
      • 支持文件搜索和过滤<br>
      • 点击文件名可跳转到文件页面<br>
      • 支持拖拽调整宽度<br><br>
      <strong>注意：</strong>需要在GitCode代码仓库页面使用
    </div>
  </div>

  <script src="popup.js"></script>
</body>
</html>

